#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
B站视频下载器 PyQt6版本启动脚本
快速启动现代化UI版本
"""

import sys
import os
from pathlib import Path

def check_dependencies():
    """
    检查依赖包是否安装
    """
    required_packages = [
        'PyQt6',
        'requests',
        'yt_dlp'
    ]
    
    missing_packages = []
    
    for package in required_packages:
        try:
            __import__(package)
        except ImportError:
            missing_packages.append(package)
    
    if missing_packages:
        print("❌ 缺少以下依赖包:")
        for package in missing_packages:
            print(f"   - {package}")
        print("\n请运行以下命令安装依赖:")
        print("pip install -r requirements_qt.txt")
        return False
    
    return True

def main():
    """
    主启动函数
    """
    print("🚀 B站视频下载器 PyQt6版本")
    print("=" * 40)
    print("版本: v2.0.0")
    print("UI框架: PyQt6")
    print("主题: 现代化深色主题")
    print("=" * 40)
    
    # 检查Python版本
    if sys.version_info < (3, 8):
        print("❌ 需要Python 3.8或更高版本")
        print(f"当前版本: {sys.version}")
        sys.exit(1)
    
    print(f"✅ Python版本: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
    
    # 检查依赖
    print("🔍 检查依赖包...")
    if not check_dependencies():
        sys.exit(1)
    
    print("✅ 依赖检查通过")
    
    # 设置工作目录
    script_dir = Path(__file__).parent
    os.chdir(script_dir)
    
    # 启动应用
    print("🎨 启动现代化UI...")
    try:
        from main_qt import main as qt_main
        qt_main()
    except KeyboardInterrupt:
        print("\n👋 用户中断，程序退出")
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        import traceback
        traceback.print_exc()
        sys.exit(1)

if __name__ == "__main__":
    main()